#include "FPCH.h"

#include "FTextInstructionsUtf16.h"

namespace Font
{

	TextInstructionsUtf16::TextInstructionsUtf16(Library* a_Library) : TextInstructions(a_Library)
	{
		
	}
	
	TextInstructionsUtf16::~TextInstructionsUtf16()
	{
		
	}

	bool TextInstructionsUtf16::AdvanceCommand()
	{
		if (m_StringCurrent[0] == 0) 
		{ 
			SetCommand(Instruction::eEndOfData);

			return false;
		}
		else if (m_StringCurrent[0] == L'\r')
		{
			if (m_StringCurrent[1] == L'\n') { m_StringCurrent++; }

			SetCommand(Instruction::eNewLine);
		}
		else if (m_StringCurrent[0] == L'\n')
		{
			SetCommand(Instruction::eNewLine);
		}
		else if (m_StringCurrent[0] == L'\t')
		{
			SetCommand(Instruction::eTab);
		}
		else
		{
			SetCommand(Instruction::eCodePoint, (unsigned int)m_StringCurrent[0]);
		}

		m_StringCurrent++;

		return true;
	}

	bool TextInstructionsUtf16::SetTextData(const unsigned char* a_String)
	{
		m_StringCurrent = (const wchar_t*)a_String;
		m_TextLength = wcslen(m_StringCurrent);

		return true;
	}

}; // namespace Font